Skip to main content

How to Upload and Use Data

This guide demonstrates how to upload data to the DAFNI platform and incorporate it into a model. We use a DAFNI model example from GitHub, which includes a spreadsheet dataset on French traffic accidents and a Python model that uses this data. The contents of the example are as follows:

.
├── BAAC_2021.xlsx
├── Dockerfile
├── main.py
├── model_definition.yaml
├── README.md
├── requirements.txt
└── TrafficAcc.ipynb

Upload Data

In the DAFNI platform, navigate to the Data section in the sidebar and click Add Data.

Model Upload Page

Click Browse files to upload the file (e.g., BAAC_2021.xlsx). Provide the required metadata. Click Publish as shown below.

Model Upload Page

Check Uploaded Data

In the Data section, confirm that the uploaded file (e.g., BAAC_2021.xlsx) appears along with its metadata. Copy the Data Version ID (for example, e5248996-abe4-470d-b11e-3edf59ff4d00) to reference in your model definition.

Model Upload Page

Create Model

Next, update the model_definition.yaml file to include the Data Version ID you copied, as shown below:

kind: M
api_version: v1beta3
metadata:
display_name: FrenchTraffic Example Model
name: sk-test-excel
publisher: SK Test
contact_point_name: DAFNI
contact_point_email: info@dafni.ac.uk
summary: >
Test reading in of excel MS spreadsheets, and uploading a basic model scenario.
description: >
Test script: reads in some road accident data from an excel MS spreadsheet, does some minor data shuffling.
Saves the data to
source_code: inc. later

spec:
inputs:
parameters:
- name: ISDAFNI
title: Running on DAFNI
type: boolean
default: True
description: True or False
required: True
dataslots:
- name: Accident Data (France fr.gov)
description: >
Road accident Data. Collected by the French Government.
default:
- e5248996-abe4-470d-b11e-3edf59ff4d00
path: inputs/
required: true
outputs:
datasets:
- name: datay.json
type: json
description: >
A Json file containing accident data % (per month), a list gives the values over a fixed year.
- name: datam.json
type: json
description: >
A Json file containing accident data % (per month), a list gives several years of a fixed mnth.

With the model and data in place, you can proceed to the next step: How to Execute the Model in DAFNI.